package com.ushine.web.base.model.system;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ushine.web.base.model.base.BaseTreeBO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Author: yls
 * @Date: 2021/3/3 9:36
 * @Description: 权限表
 * @Version 1.0
 */
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@ApiModel(description = "权限表")
@Table(name = "t_system_function_permission")
@org.hibernate.annotations.Table(appliesTo = "t_system_function_permission", comment = "权限表")
@TableName(value = "t_system_function_permission")
public class FunctionPermissionDO extends BaseTreeBO implements Serializable {
    /**
     * 编号
     * // 解决前台js接收雪花id精度丢失问题
     * JsonFormat(shape = JsonFormat.Shape.STRING)
     */
    @Id
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty("编号")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @Column(name = "id", columnDefinition = "bigint comment '编号'")
    private Long id;

    /**
     * 类型
     */
    @ApiModelProperty(value = "类型", example = "0")
    @Column(name = "type", columnDefinition = "tinyint comment '类型'")
    @NotBlank(message = "权限类型不能为空")
    private Integer type;


    /**
     * 图标
     */
    @ApiModelProperty("图标")
    @Column(name = "icon", columnDefinition = "varchar(255) comment '图标'")
    @Length(max = 255, message = "最大长度为：255")
    private String icon;

    /**
     * 路径
     */
    @ApiModelProperty("路径")
    @Column(name = "path", columnDefinition = "varchar(255) comment '路径'")
    @Length(max = 255, message = "最大长度为：255")
    private String path;

    /**
     * 排序
     */
    @ApiModelProperty("排序")
    @Column(name = "order_num", columnDefinition = "int comment '排序'")
    private Integer orderNum;

    /**
     * 权限名称
     */
    @ApiModelProperty("权限名称")
    @Column(name = "title", columnDefinition = "varchar(64) comment '权限名称'")
    @NotBlank(message = "权限名称不能为空")
    @Length(max = 64, message = "最大长度为：64")
    private String title;


    /**
     * 权限代码
     */
    @ApiModelProperty("权限代码")
    @Column(name = "code", columnDefinition = "varchar(32) comment '权限代码'")
    @Length(max = 32, message = "权限代码最大长度为：32")
    private String code;


    /**
     * 逻辑删除
     * TableField => select:false (在查询的时候排除该字段)
     */
    @TableLogic
    @TableField(value = "is_deleted", fill = FieldFill.INSERT, select = false)
    @ApiModelProperty(value = "逻辑删除", example = "0")
    @Column(name = "is_deleted", columnDefinition = "datetime comment '删除标记=> 不为null：已删除，为空：未删除'")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime deleted;


}
